home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Languages / MS Cobol4.5 / DEMO / APPCDEMO / BATTLEL.CBL < prev    next >
Text File  |  1991-04-08  |  4KB  |  89 lines

  1.       $set mf ans85 noosvs
  2.       *******************************************************************
  3.       *                                                                 *
  4.       *                                                                 *
  5.       *                  (C) Micro Focus Ltd. 1990                      *
  6.       *                                                                 *
  7.       *                         BATTLEL.CBL                             *
  8.       *                                                                 *
  9.       *      COBOL Advanced Program to Program (APPC) Demonstration     *
  10.       *                                                                 *
  11.       *                         Battleships                             *
  12.       *                          player  1                              *
  13.       *                                                                 *
  14.       *******************************************************************
  15.  
  16.        WORKING-STORAGE SECTION.
  17.  
  18.        01 Player-Id            Pic x(7) value 'PLAYER1'.
  19.  
  20.       *-----------------------------------------------------------------
  21.       *    Battle-Grid defines the grid positions of different ships
  22.       *    on this side.  It is up to each player to specify these
  23.       *    positions and follow certain requirements of the game.
  24.       *
  25.       *    The requirements are:
  26.       *        - ships are identified by the following letters:
  27.       *                 A for Aircraft Carrier
  28.       *                 B for Battleship
  29.       *                 F for Frigate
  30.       *                 G for Gun Boat
  31.       *
  32.       *        - ships can be any length - it is up to the players to
  33.       *          decide how long each ship is
  34.       *
  35.       *        - ships must not be located in adjacent grid locations
  36.       *
  37.       *        - ships can only be aligned vertically or horizontally
  38.       *
  39.       *    There is no verification done on the setup you choose - so
  40.       *    it is quite possible to cheat.  You must also recompile this
  41.       *    program when you want to change the battle grid.
  42.       *
  43.       *    A possible enhancement which you may like to make yourself
  44.       *    would be to provide code which allows each player to define
  45.       *    his/her own grid details and validate the grid dynamically -
  46.       *    thus removing the need to recompile every time.
  47.       *
  48.       *-----------------------------------------------------------------
  49.  
  50.        01 Battle-Grid.
  51.        88 No-Ships-Left        value spaces.
  52.           03 filler            pic x(13) value 'BBB          '.
  53.           03 filler            pic x(13) value '    AAAA     '.
  54.           03 filler            pic x(13) value '             '.
  55.           03 filler            pic x(13) value ' B  G   F    '.
  56.           03 filler            pic x(13) value ' B      F    '.
  57.           03 filler            pic x(13) value ' B          G'.
  58.           03 filler            pic x(13) value '    G        '.
  59.           03 filler            pic x(13) value '             '.
  60.           03 filler            pic x(13) value '          FF '.
  61.  
  62.  
  63.       *-----------------------------------------------------------------
  64.        COPY "BATTLE.WKS".
  65.       *    BATTLE.WKS is a copy file that contains common
  66.       *    working-storage section items for PLAYER1 and PLAYER2
  67.       *
  68.       *-----------------------------------------------------------------
  69.  
  70.        SCREEN SECTION.
  71.       *-----------------------------------------------------------------
  72.        COPY "BATTLE.SS".
  73.       *    BATTLE.SS is a copy file containing a screen section for
  74.       *    displaying the battle field.  The screen section was designed
  75.       *    using the SCREENS utility.
  76.       *
  77.       *-----------------------------------------------------------------
  78.  
  79.        PROCEDURE DIVISION.
  80.       *-----------------------------------------------------------------
  81.        COPY "BATTLE.CPY".
  82.       *    BATTLE.CPY is a copy file containing the common procedure
  83.       *    division code for both players
  84.       *
  85.       *-----------------------------------------------------------------
  86.  
  87.  
  88.  
  89.